package com.itheima.edu.info.manager.dao;

import com.itheima.edu.info.manager.domain.Teacher;

public class TeacherDao {
    private static Teacher[] teachers = new Teacher[5];

    public int findIndexById(String id) {
        int a = -1;
        for (int i = 0; i < 5; i++) {
            if (teachers[i] != null && teachers[i].getId().equals(id)) {
                a = i;
                break;
            }
        }
        return a;
    }

    public boolean addTeacher(Teacher teacher) {
        int index = -1;
        for (int i = 0; i < 5; i++) {
            if (teachers[i] == null) {
                index = i;
                break;
            }
        }
        if (index == -1) {
            return false;
        } else {
            teachers[index] = teacher;
            return true;
        }
    }
}
